﻿function jAjaxSubmit(form, e, waitPanelId, targetToUpdate, methodName) {

    if (!$.browser.msie) {
        e.stopPropagation();
    }
    var isValid = true;

    if (typeof methodName != 'undefined') {
        isValid = methodName(form, null);
    }

    if (isValid) {
        // create the form body
        var body = $(form).serialize();
        renderContent2(targetToUpdate, waitPanelId, form.action, body, form.method);
    }
    return false;
}

function renderContent(elementId, waitElementId, url, params, dataType , callback) {
    renderContent2(elementId, waitElementId, url, params, "GET", dataType, callback);
}

function renderContent2(elementId, waitElementId, url, params, actionType, dataType, callback) {

    $("#" + waitElementId).show();

    $.ajax({
        type: actionType,
        dataType: dataType,
        url: url,
        data: params,
        success: function(result) {
            $("#" + elementId).html(result);
            $("#" + waitElementId).hide();

            if (typeof callback != 'undefined')
                callback();
        },
        error: function(error) {
            $("#" + waitElementId).hide();
            //TODO:// write your log here
        }
    });
}

function doControllerCall(url, params, actionType, callback, error) {
   
    $.post(url, params, callback, "json");
}    